package com.inno.subject.infra.basic.service.impl;

import com.inno.subject.infra.basic.entity.PlannerSubjectCategory;
import com.inno.subject.infra.basic.mapper.PlannerSubjectCategoryDao;
import com.inno.subject.infra.basic.service.PlannerSubjectCategoryService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (PlannerSubjectCategory)表服务实现类
 *
 * @author makejava
 * @since 2024-11-16 20:57:04
 */
@Service
public class PlannerSubjectCategoryServiceImpl implements PlannerSubjectCategoryService {
    @Resource
    private PlannerSubjectCategoryDao plannerSubjectCategoryDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PlannerSubjectCategory queryById(Long id) {
        return this.plannerSubjectCategoryDao.queryById(id);
    }



    /**
     * 新增数据
     *
     * @param plannerSubjectCategory 实例对象
     * @return 实例对象
     */
    @Override
    public PlannerSubjectCategory insert(PlannerSubjectCategory plannerSubjectCategory) {
        this.plannerSubjectCategoryDao.insert(plannerSubjectCategory);
        return plannerSubjectCategory;
    }

    /**
     * 修改数据
     *
     * @param plannerSubjectCategory 实例对象
     * @return 实例对象
     */
    @Override
    public PlannerSubjectCategory update(PlannerSubjectCategory plannerSubjectCategory) {
        this.plannerSubjectCategoryDao.update(plannerSubjectCategory);
        return this.queryById(plannerSubjectCategory.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.plannerSubjectCategoryDao.deleteById(id) > 0;
    }

    @Override
    public List<PlannerSubjectCategory> queryByIdList(List<Long> categoryIds) {
        return this.plannerSubjectCategoryDao.queryByIdList(categoryIds);
    }

    @Override
    public List<PlannerSubjectCategory> queryAllNotDeletedCategories() {
        return this.plannerSubjectCategoryDao.queryAllNotDeletedCategories();
    }

    @Override
    public PlannerSubjectCategory queryByCategoryName(String categoryName) {
        return this.plannerSubjectCategoryDao.queryByCategoryName(categoryName);
    }

    @Override
    public List<PlannerSubjectCategory> queryByParentId(Long id) {
        return this.plannerSubjectCategoryDao.queryByParentId(id);
    }
}
